package com.alks.function.controller.procurement;

import com.alks.common.aop.ApiRestController;
import com.alks.common.aop.Idempotent;
import com.alks.common.aop.RoleCheck;
import com.alks.common.aop.WebLogger;
import com.alks.entity.data.response.ResponseInfo;
import com.alks.function.data.request.procurement.InstructionPackageMaterialDetailsRequest;
import com.alks.function.data.request.procurement.InstructionPackageMaterialRequest;
import com.alks.function.data.request.procurement.InstructionPackageMaterialRequest2;
import com.alks.function.service.procurement.InstructionPackagingMaterialService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@ApiRestController("/InstructionPackagingMaterial")
@Slf4j
@Api(tags = {"采购部-指令包材计算"})
@RoleCheck(prgIds = {"150107"})
public class InstructionPackagingMaterialController {

    @Autowired
    private InstructionPackagingMaterialService instructionPackagingMaterialService;

    @WebLogger
    @PostMapping("/getNotCountLotNoList")
    @ApiOperation(value = "待计算指令：查询",tags = "采购部-指令包材计算")
    public ResponseInfo getNotCountLotNoList(@RequestBody InstructionPackageMaterialRequest request){
        return instructionPackagingMaterialService.getNotCountLotNoList(request);
    }

    @WebLogger
    @PostMapping("/getProcessedLotNoList")
    @ApiOperation(value = "已处理指令：查询",tags = "采购部-指令包材计算")
    public ResponseInfo getProcessedLotNoList(@RequestBody InstructionPackageMaterialRequest request){
        return instructionPackagingMaterialService.getProcessedLotNoList(request);
    }

    @WebLogger
    @PostMapping("/getInstructionPackageDetails")
    @ApiOperation(value = "指令包材明细：查询",tags = "采购部-指令包材计算")
    public ResponseInfo getInstructionPackageDetails(@RequestBody InstructionPackageMaterialRequest request){
        return instructionPackagingMaterialService.getInstructionPackageDetails(request);
    }

    @WebLogger
    @PostMapping("/addInstructionPackageDetails")
    @ApiOperation(value = "指令包材明细：添加包材",tags = "采购部-指令包材计算")
    public ResponseInfo addInstructionPackageDetails(@RequestBody InstructionPackageMaterialDetailsRequest request,@RequestParam(value = "lotNo") String lotNo){
        return instructionPackagingMaterialService.addInstructionPackageDetails(request,lotNo);
    }

    @WebLogger
    @PostMapping("/addBatchInstructionPackageDetails")
    @ApiOperation(value = "指令包材明细：批量添加包材",tags = "采购部-指令包材计算")
    public ResponseInfo addBatchInstructionPackageDetails(@RequestBody List<InstructionPackageMaterialDetailsRequest> list,@RequestParam(value = "lotNo") String lotNo){
        return instructionPackagingMaterialService.addBatchInstructionPackageDetails(list,lotNo);
    }

    @WebLogger
    @PostMapping("/updateInstructionPackageDetails")
    @ApiOperation(value = "指令包材明细： 编辑",tags = "采购部-指令包材计算")
    public ResponseInfo updateInstructionPackageDetails(@RequestBody InstructionPackageMaterialDetailsRequest request){
        return instructionPackagingMaterialService.updateInstructionPackageDetails(request);
    }

    @WebLogger
    @PostMapping("/updateBatchInstructionPackageDetails")
    @ApiOperation(value = "指令包材明细： 批量编辑",tags = "采购部-指令包材计算")
    public ResponseInfo updateBatchInstructionPackageDetails(@RequestBody List<InstructionPackageMaterialDetailsRequest> list){
        return instructionPackagingMaterialService.updateBatchInstructionPackageDetails(list);
    }

    @WebLogger
    @PostMapping("/deleteInstructionPackageDetails")
    @ApiOperation(value = "删除打勾材料",tags = "采购部-指令包材计算")
    public ResponseInfo deleteInstructionPackageDetails(@RequestBody List<InstructionPackageMaterialDetailsRequest> request){
        return instructionPackagingMaterialService.deleteInstructionPackageDetails(request);
    }
    @WebLogger
    @GetMapping("/deleteAllInstructionPackageDetails")
    @ApiOperation(value = "删除包材用量（整单）",tags = "采购部-指令包材计算")
    public ResponseInfo deleteAllInstructionPackage(@RequestParam String lotNo){
        return instructionPackagingMaterialService.deleteAllInstructionPackage(lotNo);
    }

    @WebLogger
    @PostMapping("/makeMaterialCode")
    @ApiOperation(value = "生成物料编码",tags = "采购部-指令包材计算")
    public ResponseInfo makeMaterialCode(@RequestBody InstructionPackageMaterialDetailsRequest request){
        return instructionPackagingMaterialService.makeMaterialCode(request);
    }

    @WebLogger
    @PostMapping("/makeMaterialCodeBeNull")
    @ApiOperation(value = "指令包材明细：置空物料编码",tags = "采购部-指令包材计算")
    public ResponseInfo makeMaterialCodeBeNull(@RequestBody InstructionPackageMaterialDetailsRequest request){
        return instructionPackagingMaterialService.makeMaterialCodeBeNull(request);
    }

    @WebLogger
    @PostMapping("/calculatedConsumption")
    @ApiOperation(value = "打勾计算用量",tags = "采购部-指令包材计算")
    public ResponseInfo calculatedConsumption(@RequestBody List<InstructionPackageMaterialRequest> request){
        return instructionPackagingMaterialService.calculatedConsumption(request);
    }

    @WebLogger
    @PostMapping("/copyInstructionPackageDetails")
    @ApiOperation(value = "复制到勾选指令",tags = "采购部-指令包材计算")
    public ResponseInfo copyInstructionPackageDetails(@RequestBody InstructionPackageMaterialRequest2 request){
        return instructionPackagingMaterialService.copyInstructionPackageDetails(request);
    }

    @WebLogger
    @PostMapping("/updateClickDetails")
    @ApiOperation(value = "材料替换",tags = "采购部-指令包材计算")
    public ResponseInfo updateClickDetails(@RequestBody InstructionPackageMaterialRequest2 request){
        return instructionPackagingMaterialService.updateClickDetails(request);
    }

    @WebLogger
    @GetMapping("/getSizeListByStyle")
    @ApiOperation(value = "根据形体查size",tags = "采购部-指令包材计算")
    public ResponseInfo getSizeListByStyle(@RequestParam(value = "style") String style){
        return instructionPackagingMaterialService.getSizeListByStyle(style);
    }

    @WebLogger
    @PostMapping("/getLotNoList")
    @ApiOperation(value = "包材订购指令查询",tags = "采购部-指令包材计算")
    public ResponseInfo getLotNoList(@RequestBody InstructionPackageMaterialRequest request){
        return instructionPackagingMaterialService.getProcessedLotNoList(request);
    }

    @WebLogger
    @GetMapping("/updateDate")
    @ApiOperation(value = "根据指令更新鞋托数据",tags = "采购部-指令包材计算")
    public ResponseInfo updateDate(@RequestParam String lotNo){
        return instructionPackagingMaterialService.updateDate(lotNo);
    }
}
